<template>
  <div>
    <el-form ref="orderForm" :model="form" label-width="85px">
      <el-row>
        <el-col :md="7" :lg="6">
          <el-form-item label="订单号:">
            <el-input
              v-model="form.ordernum"
              size="medium"
              placeholder="请输入订单号"
            />
          </el-form-item>
        </el-col>
        <el-col :md="7" :lg="6">
          <el-form-item label="车编号:">
            <el-input
              v-model="form.cid"
              size="medium"
              placeholder="请输入车编号"
            />
          </el-form-item>
        </el-col>
        <el-col :md="7" :lg="6">
          <el-form-item label="车牌号:">
            <el-input
              v-model="form.number"
              size="medium"
              placeholder="请输入车牌号"
            />
          </el-form-item>
        </el-col>
        <el-col :md="3" :lg="6" style="text-align: right">
          <el-button
            type="primary"
            size="medium"
            @click="onSubmit('orderForm')"
          >
            搜索
          </el-button>
        </el-col>
      </el-row>
      <el-col :md="7" :lg="6">
        <el-form-item label="手机号码:">
          <el-input
            v-model="form.tel"
            size="medium"
            placeholder="请输入手机号码"
          />
        </el-form-item>
      </el-col>
      <el-row>
        <el-col :md="7" :lg="6">
          <el-form-item label="下单日期:">
            <el-date-picker
              v-model="form.ordertime"
              type="date"
              size="medium"
              placeholder="请选择日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
            />
          </el-form-item>
        </el-col>
        <el-col :md="7" :lg="6">
          <el-form-item label="取车日期:">
            <el-date-picker
              v-model="form.picktime"
              type="date"
              size="medium"
              placeholder="请选择日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
            />
          </el-form-item>
        </el-col>
        <el-col :md="9" :lg="6">
          <el-form-item label="还车日期:">
            <el-date-picker
              v-model="form.returntime"
              type="date"
              size="medium"
              placeholder="请选择日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'OrderForm',
  data() {
    return {
      form: {
        ordernum: '',
        cid: '',
        number: '',
        tel: '',
        ordertime: '',
        picktime: '',
        returntime: ''
      }
    }
  },
  methods: {
    onSubmit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$emit('on-success-valid', {
            ordernum: this.form.ordernum,
            cid: this.form.cid,
            number: this.form.number,
            tel: this.form.tel,
            ordertime: this.form.ordertime,
            picktime: this.form.picktime,
            returntime: this.form.returntime
          })
        } else {
          return false
        }
      })
    }
  }
}
</script>
<style scoped>
/* .el-date-editor.el-input, .el-date-editor.el-input__inner {
  width: 100%
} */
.el-input{
  width: 160px;
}
</style>
